package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.util.ProdCateUtil;
import com.iwhalecloud.bss.kite.manager.api.IOperateSceneInstService;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.manager.inst.KiteOfferInst;
import com.iwhalecloud.bss.kite.manager.inst.KiteProdInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import org.springframework.beans.factory.annotation.Autowired;

public class BusinessScenariosAttrHandler extends AbstractAttrHandler<KiteProdInst, AttrData> {

    @Autowired
    private IOperateSceneInstService operateSceneInstService;
    @Autowired
    IQuerySceneInstService querySceneInstService;

    @Override
    public void after(KiteAttr attr, KiteProdInst inst, AttrData data) {
        KiteOfferInst offerInst = querySceneInstService.getMainOfferInst(data.getSceneInstId());
        String offerId = offerInst.getOfferId();
        if("50040701".equals(offerId)){
            attr.setDefaultValue("100001822");

        }
        super.after(attr, inst, data);
        if (KiteStringUtils.isEqual(data.getServiceOfferId(), "2826")
            && KiteStringUtils.equalsAny(inst.getSpecId(), ProdCateUtil.getMainMemberProdId(ProdCateUtil.GIFT_DZ5G_PROD))) {
            attr.setIsEdit(KeyConsts.IFTRUE_T);
            operateSceneInstService
                .setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr);
        }
    }
}
